package com.jumi.microservice.controller.logistics.admin;

import com.jumi.microservice.common.base.BaseController;
import com.jumi.microservice.common.base.dto.ResponseResult;
import com.jumi.microservice.domain.ExpressDataDTO;
import com.jumi.microservice.dto.logistics.admin.EditOrPartSendRequest;
import com.jumi.microservice.dto.logistics.admin.UpdateRealLogisticsNoRequest;
import com.jumi.microservice.service.logistics.admin.SelfWaitSendService;
import com.jumi.microservice.service.logistics.admin.SendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;
import java.util.Set;

/**
 * @author by mazhao
 * @Classname EditSendController
 * @Description TODO
 * @Date 2020/8/24 11:12
 */
@RestController
@RequestMapping("/admin/logistics/")
@Api(tags = {"编辑发货相关接口"})
public class EditSendController extends BaseController {

    @Resource
    SendService sendService;

    @Resource
    SelfWaitSendService selfWaitSendService;

    @ApiOperation("订单编辑发货提交")
    @PostMapping("/editSend")
    public ResponseResult<Boolean> editSend(EditOrPartSendRequest request){
        Long uid = getUid();
        String name = getUserName();
        return success(sendService.editSendSubmit(request,uid,name));
    }

    @ApiOperation("快递公司")
    @PostMapping("/expressList")
    public ResponseResult<List<ExpressDataDTO>> getExpressList(){
        return success(sendService.getExpressList());
    }

    @ApiOperation("取消包裹")
    @PostMapping("/cancelLogistics")
    public Boolean cancelLogistics(Integer orderId){
        return sendService.cancelLogistics(orderId);
    }

    @ApiOperation("获取真实物流单号列表")
    @PostMapping("/realLogisticsNoList")
    public ResponseResult<Set<String>> realLogisticsNoList(UpdateRealLogisticsNoRequest request){
        return success(sendService.realLogisticsNoList(request));
    }

    @ApiOperation("修改真实物流单号")
    @PostMapping("/updateRealLogisticsNo")
    public ResponseResult<Boolean> updateRealLogisticsNo(UpdateRealLogisticsNoRequest request){
        Long uid = getUid();
        String name = getUserName();
        return success(sendService.updateRealLogisticsNo(request,uid,name));
    }

    @ApiOperation("导入EXCEL批量修改真实物流单号")
    @PostMapping("/batchUpdateRealLogisticsNo")
    public ResponseResult<List<String>> batchUpdateRealLogisticsNo(HttpServletRequest request) throws IOException {
        Long uid = getUid();
        String name = getUserName();
        return success(selfWaitSendService.batchUpdateRealLogisticsNo(request,uid,name));
    }

}
